<?php
class ImagesController extends AppController {

	var $name = 'Images';

	function index() {

	}

	function show($model = null, $id = null) {
		if ($id && $model) {
			if ($model == 'preview') {
				$m = 'Fotopreview';
			} elseif ($model == 'foto') {
				$m = 'Foto';
			}

			if (isset($m)) {
				$this->loadModel($m);
				$img = $this->$m->getFoto($id);
			}

			if($img) {
				header('Content-type: ' . $img[$m]['type']);
				//header('Content-length: ' . $img[$m]['size']);
				header('Content-Disposition: attachment; filename='.$img[$m]['name']);
				echo $img[$m]['content'];
			}
		}

	}

}
?>
